package com.newcapec.servlet;

import com.newcapec.bean.ColumnEntity;
import com.newcapec.bean.NewsEntity;
import com.newcapec.service.ColumnService;
import com.newcapec.service.NewsService;
import com.newcapec.service.impl.ColumnServiceImpl;
import com.newcapec.service.impl.NewsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description:显示前端主界面的servlet类
 * @Author:yangshupeng
 * @Date: 2022/3/21 22:11
 * @Version:1.0
 */
@WebServlet("/newsContent.html")
public class ShowNewsContentHtmlServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        String columnId = req.getParameter("columnId");
        NewsService newsService = new NewsServiceImpl();
        NewsEntity newsEntity = newsService.queryById(id);


        req.setAttribute("newsEntity",newsEntity);
        req.setAttribute("columnId",columnId);
        //请求转发
        req.getRequestDispatcher("web/news_content.jsp").forward(req,resp);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
